package cn.daniellee.plugin.lm.menu;

import cn.daniellee.plugin.lm.LotteryMaster;
import cn.daniellee.plugin.lm.component.ItemGenerator;
import org.bukkit.Bukkit;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;

public class SettingMenu {

	public static Inventory generate() {
		Inventory menu = Bukkit.createInventory(new EditMenuHolder(), InventoryType.HOPPER, LotteryMaster.getInstance().getConfig().getString("menu.edit.title", "&6&lEdit building").replace("&", "§"));

		// 填充角
		int cornerPosition[] = new int[]{ 1, 3 };
		for (int i : cornerPosition) menu.setItem(i, Common.getCorner());

		menu.setItem(0, ItemGenerator.getItem(LotteryMaster.getInstance().getConfig().getString("menu.edit.button.name.name", "&bModify name"), LotteryMaster.getInstance().getConfig().getStringList("menu.edit.button.name.lore"), LotteryMaster.getInstance().getConfig().getString("menu.edit.button.name.item.material", "WRITABLE_BOOK"), LotteryMaster.getInstance().getConfig().getInt("menu.edit.button.name.item.durability", 0)));

		menu.setItem(2, ItemGenerator.getItem(LotteryMaster.getInstance().getConfig().getString("menu.edit.button.location.name", "&bReset teleport point"), LotteryMaster.getInstance().getConfig().getStringList("menu.edit.button.location.lore"), LotteryMaster.getInstance().getConfig().getString("menu.edit.button.location.item.material", "ENDER_PEARL"), LotteryMaster.getInstance().getConfig().getInt("menu.edit.button.location.item.durability", 0)));

		menu.setItem(4, ItemGenerator.getItem(LotteryMaster.getInstance().getConfig().getString("menu.edit.button.delete.name", "&bDelete building"), LotteryMaster.getInstance().getConfig().getStringList("menu.edit.button.delete.lore"), LotteryMaster.getInstance().getConfig().getString("menu.edit.button.delete.item.material", "TNT"), LotteryMaster.getInstance().getConfig().getInt("menu.edit.button.delete.item.durability", 0)));

		return menu;
	}

	public static class EditMenuHolder implements InventoryHolder {
		@Override
		public Inventory getInventory() {
			return Bukkit.createInventory(null, InventoryType.HOPPER);
		}
	}
}
